<?php
/**
 * @author shuang
 * @date 2016-10-27 10:40:40
 */
$this->title = "任务大厅";

use yii\helpers\Url;
use common\components\MTools;
use yii\helpers\ArrayHelper;

$this->registerJsFile('/js/task.js', [\frontendm\assets\AppAsset::className(), "depends" => "frontendm\assets\AppAsset"]);
$this->registerJs('task.init({taskBtn:".getvt",taskUrl:"' . Url::toRoute(["validatetask"]) . '"})', 3);
?>
<div class="weui_tab">
    <div class="weui_navbar">
        <a class="weui_navbar_item <?php echo $type == null ? "weui_bar_item_on" : null; ?>" href="<?php echo Url::toRoute(["work"]); ?>">全部</a>
        <?php foreach (MTools::dictDropdown("task_type") as $item): ?>
            <a class="weui_navbar_item <?php echo $type == $item["id"] ? "weui_bar_item_on" : null; ?>" href="<?php echo Url::toRoute(["work", "type" => ArrayHelper::getValue($item, "id")]); ?>"><?php echo ArrayHelper::getValue($item, "name"); ?></a>
        <?php endforeach; ?>
    </div>
    <div class="weui_tab_bd">
        <div class="weui_panel">
            <?php foreach ($topdata as $item): ?>
                <div class="weui_panel_bd">
                    <div class="weui_media_box weui_media_text">
                        <h4 class="weui_media_title">
                            <a href="javascript:;" class="pull-left"><?php echo ArrayHelper::getValue($item, "title"); ?><?php ArrayHelper::getValue($item, "is_speed") == 1 ? "<span class='redcolor'>[限速]</span>" : null; ?></a>
                            <a href="javascript:;" data-tasknum="<?php echo MTools::IntFormat($item["number"] - $item["taskcount"]); ?>" data-taskid="<?php echo ArrayHelper::getValue($item, "id"); ?>"  class="getvt weui_btn weui_btn_mini weui_btn_primary pull-right" onclick="javascript:getvtBind(this);">开始任务</a>
                        </h4>
                        <ul class="weui_media_info">
                            <li class="weui_media_info_meta">￥<?php echo Yii::$app->formatter->asDecimal($item["brush_price"]); ?></li>
                            <li class="weui_media_info_meta">剩余：<?php echo MTools::IntFormat($item["number"] - $item["taskcount"]); ?></li>
                            <li class="weui_media_info_meta weui_media_info_meta_extra">可接次数：<?php echo MTools::IntFormat($item["single_meet"]); ?></li>
                        </ul>
                    </div>
                </div>
            <?php endforeach; ?>
            <?php foreach ($data as $item): ?>
                <div class="weui_panel_bd">
                    <div class="weui_media_box weui_media_text">
                        <h4 class="weui_media_title">
                            <a href="javascript:;" class="pull-left"><?php echo ArrayHelper::getValue($item, "title"); ?><?php ArrayHelper::getValue($item, "is_speed") == 1 ? "<span class='redcolor'>[限速]</span>" : null; ?></a>
                            <a href="javascript:;" data-tasknum="<?php echo MTools::IntFormat($item["number"] - $item["taskcount"]); ?>" data-taskid="<?php echo ArrayHelper::getValue($item, "id"); ?>"  class="getvt weui_btn weui_btn_mini weui_btn_primary pull-right" onclick="javascript:getvtBind(this);">开始任务</a>
                        </h4>
                        <ul class="weui_media_info">
                            <li class="weui_media_info_meta">价格：￥<?php echo Yii::$app->formatter->asDecimal($item["brush_price"]); ?></li>
                            <li class="weui_media_info_meta">剩余：<?php echo MTools::IntFormat($item["number"] - $item["taskcount"]); ?></li>
                            <li class="weui_media_info_meta weui_media_info_meta_extra">可接次数：<?php echo MTools::IntFormat($item["single_meet"]); ?></li>
                        </ul>
                    </div>

                </div>
                <div class="clearfix"></div>

            <?php endforeach; ?>
        </div>
          <div class="pagination" style="float:right;">
         <?php
        echo
        \yii\widgets\LinkPager::widget([
            'pagination' => $pager,
            'nextPageLabel' => '下一页',
            'prevPageLabel' => '上一页',
        ]);
        ?>
    </div>
    </div>
  
</div>